
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>项目构建 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-vuejs/vue.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="link.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    文档信息
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="build.html">
            
                <a href="build.html">
            
                    
                    项目构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="link.html">
            
                <a href="link.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    基础使用
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="initMap.html">
            
                <a href="initMap.html">
            
                    
                    初始化地图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="loadJXMap.html">
            
                <a href="loadJXMap.html">
            
                    
                    加载江西地图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="LayerSwitcher.html">
            
                <a href="LayerSwitcher.html">
            
                    
                    底图切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="addPoints.html">
            
                <a href="addPoints.html">
            
                    
                    添加点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="addLine.html">
            
                <a href="addLine.html">
            
                    
                    添加线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="addPolygon.html">
            
                <a href="addPolygon.html">
            
                    
                    添加面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="CustomCIrcle.html">
            
                <a href="CustomCIrcle.html">
            
                    
                    周边搜索圆
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    进阶
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="CoordsTransform.html">
            
                <a href="CoordsTransform.html">
            
                    
                    坐标转换
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    类说明
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="class.html">
            
                <a href="class.html">
            
                    
                    map
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >项目构建</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="webgis-jsapi&#x6784;&#x5EFA;">webgis jsapi&#x6784;&#x5EFA;</h1>
<h3 id="&#x7C7B;&#x5E93;">&#x7C7B;&#x5E93;</h3>
<blockquote>
<p>&#x5728; JavaScript &#x8BED;&#x5883;&#x4E2D;&#xFF0C;&#x6211;&#x5BF9;&#x7C7B;&#x5E93;&#x7684;&#x5B9A;&#x4E49;&#x662F; &#x201C;&#x63D0;&#x4F9B;&#x4E86;&#x7279;&#x5B9A;&#x529F;&#x80FD;&#x7684;&#x4E00;&#x6BB5;&#x4EE3;&#x6BB5;&#x201D;&#x3002;
&#x4E00;&#x4E2A;&#x7C7B;&#x5E93;&#x53EA;&#x505A;&#x4E00;&#x4EF6;&#x4E8B;&#xFF0C;&#x5E76;&#x4E14;&#x628A;&#x8FD9;&#x4EF6;&#x4E8B;&#x505A;&#x597D;&#x3002;&#x5728;&#x7406;&#x60F3;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;
&#x5B83;&#x4E0D;&#x4F9D;&#x8D56;&#x5176;&#x5B83;&#x7C7B;&#x5E93;&#x6216;&#x6846;&#x67B6;&#x3002;jQuery &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5F88;&#x597D;&#x7684;&#x4F8B;&#x5B50;&#x3002;
React &#x6216;&#x8005; Vue.js &#x4E5F;&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#x5E93;&#x3002;</p>
<p><strong>&#x4E00;&#x4E2A;&#x7C7B;&#x5E93;&#x5E94;&#x8BE5;&#xFF1A;</strong></p>
<blockquote>
<ul>
<li>&#x53EF;&#x4EE5;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x73AF;&#x5883;&#x4E0B;&#x4F7F;&#x7528;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span></code>&#x6807;&#x7B7E;&#x6765;&#x5F15;&#x5165;&#x8FD9;&#x4E2A;&#x7C7B;&#x5E93;&#x3002;</li>
<li>&#x53EF;&#x4EE5;&#x901A;&#x8FC7; npm &#x6765;&#x5B89;&#x88C5;&#x3002;</li>
<li>&#x517C;&#x5BB9; ES6(ES2015) &#x7684;&#x6A21;&#x5757;&#x7CFB;&#x7EDF;&#x3001;CommonJS &#x548C; AMD &#x6A21;&#x5757;&#x89C4;&#x8303;&#x3002;</li>
</ul>
</blockquote>
</blockquote>
<h3 id="&#x76EE;&#x5F55;&#x7ED3;&#x6784;">&#x76EE;&#x5F55;&#x7ED3;&#x6784;</h3>
<pre class="language-"><code>ES6 source files
       |
       |
    webpack
       |
       +--- babel, eslint
       |
  ready to use
     library
  in umd format
</code></pre><h1 id="webpack-library-starter">Webpack library starter</h1>
<p>Webpack based boilerplate for producing libraries (Input: ES6, Output: universal library)</p>
<h2 id="features">Features</h2>
<ul>
<li>Webpack 2 based.</li>
<li>ES6 as a source.</li>
<li>Exports in a <a href="https://github.com/umdjs/umd" target="_blank">umd</a> format so your library works everywhere.</li>
<li>ES6 test setup with <a href="http://mochajs.org/" target="_blank">Mocha</a> and <a href="http://chaijs.com/" target="_blank">Chai</a>.</li>
<li>Linting with <a href="http://eslint.org/" target="_blank">ESLint</a>.</li>
</ul>
<h2 id="process">Process</h2>
<p><em>Have in mind that you have to build your library before publishing. The files under the <code>lib</code> folder are the ones that should be distributed.</em></p>
<h2 id="getting-started">Getting started</h2>
<ol>
<li>Setting up the name of your library<ul>
<li>Open <code>webpack.config.js</code> file and change the value of <code>libraryName</code> variable.</li>
<li>Open <code>package.json</code> file and change the value of <code>main</code> property so it matches the name of your library.</li>
</ul>
</li>
<li>Build your library<ul>
<li>Run <code>npm install</code> to get the project&apos;s dependencies</li>
<li>Run <code>npm run build</code> to produce minified version of your library.</li>
</ul>
</li>
<li>Development mode<ul>
<li>Having all the dependencies installed run <code>npm run dev</code>. This command will generate an non-minified version of your library and will run a watcher so you get the compilation on file change.</li>
</ul>
</li>
<li>Running the tests<ul>
<li>Run <code>npm run test</code></li>
</ul>
</li>
</ol>
<h2 id="scripts">Scripts</h2>
<ul>
<li><code>npm run build</code> - produces production version of your library under the <code>lib</code> folder</li>
<li><code>npm run dev</code> - produces development version of your library and runs a watcher</li>
<li><code>npm run test</code> - well ... it runs the tests :)</li>
<li><code>npm run test:watch</code> - same as above but in a watch mode</li>
</ul>
<h2 id="readings">Readings</h2>
<ul>
<li><a href="http://krasimirtsonev.com/blog/article/javascript-library-starter-using-webpack-es6" target="_blank">Start your own JavaScript library using webpack and ES6</a></li>
</ul>
<h2 id="misc">Misc</h2>
<h3 id="an-example-of-using-dependencies-that-shouldnt-be-resolved-by-webpack-but-should-become-dependencies-of-the-resulting-bundle">An example of using dependencies that shouldn&#x2019;t be resolved by webpack, but should become dependencies of the resulting bundle</h3>
<p>In the following example we are excluding React and Lodash:</p>
<pre class="language-"><code class="lang-js"><span class="token punctuation">{</span>
  devtool<span class="token punctuation">:</span> <span class="token string">&apos;source-map&apos;</span><span class="token punctuation">,</span>
  output<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    path<span class="token punctuation">:</span> <span class="token string">&apos;...&apos;</span><span class="token punctuation">,</span>
    libraryTarget<span class="token punctuation">:</span> <span class="token string">&apos;umd&apos;</span><span class="token punctuation">,</span>
    library<span class="token punctuation">:</span> <span class="token string">&apos;...&apos;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  entry<span class="token punctuation">:</span> <span class="token string">&apos;...&apos;</span><span class="token punctuation">,</span>
  <span class="token operator">...</span>
  externals<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    react<span class="token punctuation">:</span> <span class="token string">&apos;react&apos;</span>
    <span class="token comment" spellcheck="true">// Use more complicated mapping for lodash.</span>
    <span class="token comment" spellcheck="true">// We need to access it differently depending</span>
    <span class="token comment" spellcheck="true">// on the environment.</span>
    lodash<span class="token punctuation">:</span> <span class="token punctuation">{</span>
      commonjs<span class="token punctuation">:</span> <span class="token string">&apos;lodash&apos;</span><span class="token punctuation">,</span>
      commonjs2<span class="token punctuation">:</span> <span class="token string">&apos;lodash&apos;</span><span class="token punctuation">,</span>
      amd<span class="token punctuation">:</span> <span class="token string">&apos;_&apos;</span><span class="token punctuation">,</span>
      root<span class="token punctuation">:</span> <span class="token string">&apos;_&apos;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="&#x4FEE;&#x6539;-proj4&#x91CC;&#x9762;&#x7684;&#x4E24;&#x4E2A;&#x4FDD;&#x6301;&#x8DEF;&#x5F84;&#x6B63;&#x786E;">&#x4FEE;&#x6539; proj4&#x91CC;&#x9762;&#x7684;&#x4E24;&#x4E2A;&#x4FDD;&#x6301;&#x8DEF;&#x5F84;&#x6B63;&#x786E;</h2>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">var</span> proj4 <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./core&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>defaultDatum <span class="token operator">=</span> <span class="token string">&apos;WGS84&apos;</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//default datum</span>
proj4<span class="token punctuation">.</span>Proj <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./Proj&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>WGS84 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">proj4<span class="token punctuation">.</span>Proj</span><span class="token punctuation">(</span><span class="token string">&apos;WGS84&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>Point <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./Point&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>toPoint <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./common/toPoint&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>defs <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./defs&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>transform <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./transform&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>mgrs <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;../../mgrs&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
proj4<span class="token punctuation">.</span>version <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./version&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&apos;./includedProjections&apos;</span><span class="token punctuation">)</span><span class="token punctuation">(</span>proj4<span class="token punctuation">)</span><span class="token punctuation">;</span>
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> proj4<span class="token punctuation">;</span>
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 文档信息">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="link.html" class="navigation navigation-next " aria-label="Next page: 安装">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"项目构建","level":"1.2","depth":1,"next":{"title":"安装","level":"1.3","depth":1,"path":"link.md","ref":"link.md","articles":[]},"previous":{"title":"文档信息","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git","-fontsettings","-highlight","github","livereload"],"root":"./api","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/smileFDD/HMap.git"},"livereload":{},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"编辑此页","base":"https://github.com/smileFDD/HMap/tree/master/docs/api"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":">3.0.0"},"file":{"path":"build.md","mtime":"2017-03-18T03:22:18.321Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-03-18T05:20:47.112Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    

    </body>
</html>

